/**
 * 
 */
package com.pufa.demo.service;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.pufa.demo.dao.IDemoDAO;

/**
 * @author Menlin
 *
 */
@Service("serviceImpl")
public class ServiceImpl implements IService {

	private final static String sign = "p";
	@Resource IDemoDAO demoDAO;
	
	@Override
	public List<String> savePingzh(String pingzh, String size) {
		int p = Integer.parseInt(pingzh);
		int s = Integer.parseInt(size);
		List<String> list = new ArrayList<String>(s);
		for (int i = 0; i < s;i++) {
			String pzh = sign + String.format("%08d", p);
			if (demoDAO.queryByPingzh(pzh)==null)
				demoDAO.save(pzh);
			list.add(String.format("%08d", p));
			p ++;
		}
		return list;
	}

	@Override
	public boolean verifyPingzh(String pingzh) {
		String r = demoDAO.queryByPingzh(sign + pingzh);
		return (r != null);
	}

}
